package com.xzy.c;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 依赖注入的方式：<bean autowire=""/> + set方法
 *
 * @author xzy
 * @date 2021/12/6  22:34
 */
public class Main {
    public static void main(String[] args) {
//        byTypeAndSetter();
        byNameAndSetter();
    }

    public static void byTypeAndSetter() {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("c/byTypeBeanWired.xml");
        System.out.println(applicationContext.getBean(ByTypeSetterServiceImpl.class));
    }

    private static void byNameAndSetter() {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("c/byNameBeanWired.xml");
        System.out.println(applicationContext.getBean(ByNameSetterServiceImpl.class));
    }
}
